/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bancodedados3d;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author fosa
 */
class FrameInterno3d02 extends JInternalFrame {

    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel jLabel1;
    private jTable3D jTable3D1;
    private JPanel jPanel1;
    private javax.swing.JButton jButton1;

    public FrameInterno3d02(String msg, int x, int y) {
        super(msg, true, true, true);        // title, resizable, closable, maximizable
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new JLabel();

//        jTable3D1 = new jTable3D(this.getGraphicsConfiguration());
        jPanel1 = new JPanel();
        jButton1 = new JButton();

        jLabel1.setText("status: " + Main.GlConexão.getGllocal() + " " + Main.GlConexão.getGluser());

        jTextField1.setText("Select * From Contabilidade.movimentacao");
        jTextField1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });


        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton1.setText("Vai");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton1)));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton1).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
        Dimension mySize = new Dimension();
        mySize.height = Toolkit.getDefaultToolkit().getScreenSize().height / 3; // make a window based on local screen resolution
        mySize.width = Toolkit.getDefaultToolkit().getScreenSize().width / 3;
        this.setSize(mySize);
        this.setLocation(x, y);

        jTable3D1 = new jTable3D();
        this.setLayout(new BorderLayout());
        this.add(BorderLayout.PAGE_START, jPanel1);
        this.add(BorderLayout.CENTER, jTable3D1);
        this.add(BorderLayout.PAGE_END, jLabel1);

//        this.getContentPane().add(new JPanel3D(scene_type));  // add the 3D rendered object to the frame

        this.show();  // make it appear in the Desktop - needed for JDK1.3
    }

    public FrameInterno3d02(String msg, String sql, int x, int y) {
        super(msg, true, true, true);        // title, resizable, closable, maximizable
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new JLabel();

//        jTable3D1 = new jTable3D(this.getGraphicsConfiguration());
        jPanel1 = new JPanel();
        jButton1 = new JButton();

        jLabel1.setText("status: " + Main.GlConexão.getGllocal() + " " + Main.GlConexão.getGluser());

        jTextField1.setText(sql);
        jTextField1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });


        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton1.setText("Vai");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton1)));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton1).addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
        Dimension mySize = new Dimension();
        mySize.height = Toolkit.getDefaultToolkit().getScreenSize().height / 3; // make a window based on local screen resolution
        mySize.width = Toolkit.getDefaultToolkit().getScreenSize().width / 3;
        this.setSize(mySize);
        this.setLocation(x, y);

        jTable3D1 = new jTable3D();
        this.setLayout(new BorderLayout());
        this.add(BorderLayout.PAGE_START, jPanel1);
        this.add(BorderLayout.CENTER, jTable3D1);
        this.add(BorderLayout.PAGE_END, jLabel1);

//        this.getContentPane().add(new JPanel3D(scene_type));  // add the 3D rendered object to the frame

        this.show();  // make it appear in the Desktop - needed for JDK1.3
    }

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        Object[][][] tabela = Main.GlConsulta.consulta(jTextField1.getText());

        jTable3D1.setModel(tabela[1], tabela[0][0]);
    }

    private void jButton1ActionPerformed(ActionEvent evt) {
        Object[][][] tabela = Main.GlConsulta.consulta(jTextField1.getText());

        jTable3D1.setModel(tabela[1], tabela[0][0]);
    }
}